<?php 
class Mcrypt
{
	private static function getkey()
	{
		return md5('nimahgh');
		
	}
	public $data='';
	
	function set_mcrypt($d)
	{
		$m=mcrypt_module_open('rijndael-256', '', 'cbc', '');
		$vi=mcrypt_create_iv(mcrypt_enc_get_iv_size($m),MCRYPT_DEV_RANDOM);
		$key=self::getkey();
		mcrypt_generic_init($m, $key, $vi);
		$data=mcrypt_generic($m, $d);
		mcrypt_generic_deinit($m);
 		mcrypt_module_close($m);
		return base64_encode($data);
	}
	function read_mcrypt($v)
	{   $m=mcrypt_module_open('rijndael-256', '', 'cbc', '');
		$vi=mcrypt_create_iv(mcrypt_enc_get_iv_size($m),MCRYPT_DEV_RANDOM);
		$key=self::getkey();
		mcrypt_generic_init($m, $key, $vi);
		$h=mdecrypt_generic($m, base64_decode($v));
		mcrypt_generic_deinit($m);
 		mcrypt_module_close($m);
 		return trim($h);

		
	}
	
}
 ?>